package course.cmsc436.medicationmanager;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import course.cmsc436.medication.Medication;

public class MainActivity extends Activity {

	static private Medication m = new Medication("Fakepilz");
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}
	
	public void onDebugClick(View v) {
		Intent i = new Intent(this, UPCTestActivity.class);
		this.startActivity(i);
	}
	
	public void onClickScanSearch(View v) {
		Intent i = new Intent(this, MainScanActivity.class);
		this.startActivity(i);
	}
	
	public void onSetAlarm(View v) {
		Calendar c = Calendar.getInstance();
		c.add(Calendar.SECOND, 5);
		ArrayList<Date> al = new ArrayList<Date>();
		al.add(c.getTime());
		m.setTimes(al);
		AlarmScheduler.scheduleAlarm(this, m);
	}
	
	public void onClearAlarm(View v) {
		AlarmScheduler.cancelAlarm(this, m);
	}
}
